import { newRequest } from '@/utils/newRequest'
import Router from '@/router'
import request from '@/utils/request'

export function getLineList(params) {
    return newRequest({
        url: '/api/BasicsData/GetLineList',
        method: 'get',
        params: {
            ...params
        }
    })
}
export function GetKMAnd750Line(params) {
  return newRequest({
    url:'/api/Line/GetKMAnd750Line',
    method:'get',
    params
  })
}



export function insertLine(data) {
    return newRequest({
        url: '/api/basicsData/InsertLine',
        method: 'post',
        data: {
            ...data
        }
    })
}
export function updateLine(data) {
    return newRequest({
        url: '/api/basicsData/UpdateLine',
        method: 'post',
        data: {
            ...data
        }
    })
}
export function removeLine(data) {
    return newRequest({
        url: '/api/basicsData/RemoveLine',
        method: 'post',
        data: {
            ...data
        }
    })
}
export function startOrStopLine(data) {
    return newRequest({
        url: '/api/basicsData/StartOrStopLine',
        method: 'post',
        data: {
            ...data
        }
    })
}

export function getAllLineList(params) {
    return newRequest({
        url: '/api/BasicsData/GetAllLineList',
        method: 'get',
        params: {
            ...params
        }
    })
}

export function getUserLineList(params) {
  // console.log('Router   => .  %o',Router);
  const wsp = Router.currentRoute.meta?.WorkStationPermissions ?? []
  console.log('wsp');
  console.log(wsp);
  console.log(Router.currentRoute);


  return request({
        url: '/api/BasicsData/GetUserLineList',
        method: 'get',
        params: {
            ...params,
          workStation:wsp.map(v => v.WorkstationId).join(',')
        }
    })
}
